package com.game.fighting.component;

import com.almasb.fxgl.dsl.components.LiftComponent;
import com.almasb.fxgl.entity.component.Component;
import com.almasb.fxgl.physics.BoundingShape;
import com.almasb.fxgl.physics.HitBox;
import javafx.geometry.Point2D;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.util.Duration;

/**
 * @author LeeWyatt
 */
public class TargetComponent extends Component {

    @Override
    public void onAdded() {
        Rectangle rect1 = new Rectangle(8,20, new Color( 0.96, 0.96, 0.24, 1.0));
        Rectangle rect2 = new Rectangle(8,60, new Color( 0.24, 0.62, 1.0, 1.0));
        rect2.setTranslateX(8);
        rect2.setTranslateY(-20);
        Rectangle rect3 = new Rectangle(8,120, Color.WHITE);
        rect3.setTranslateX(16);
        rect3.setTranslateY(-50);
        entity.getViewComponent().addChild(rect1);
        entity.getViewComponent().addChild(rect2);
        entity.getViewComponent().addChild(rect3);

        entity.getBoundingBoxComponent().addHitBox(
                new HitBox("high", BoundingShape.box(8, 20)));
        entity.getBoundingBoxComponent().addHitBox(
                new HitBox("middle", new Point2D(8, -20),BoundingShape.box(8, 60)));
        entity.getBoundingBoxComponent().addHitBox(
                new HitBox("low", new Point2D(16,-50),BoundingShape.box(8, 120)));

        LiftComponent liftComponent = new LiftComponent();
        liftComponent.setGoingUp(true);
        liftComponent.yAxisDistanceDuration(-180, Duration.seconds(1.8));
        entity.addComponent(liftComponent);
    }



}
